package org.Image.management.ViewController;

import javafx.application.Application;
import javafx.application.Platform;
import javafx.scene.Scene;
import javafx.stage.Stage;
import lombok.extern.slf4j.Slf4j;
import org.Image.management.SpringBootImageManagementApplication;
import org.Image.management.ViewCofig.file.FxmlPath;
import org.Image.management.ViewCofig.file.IconPath;
import org.Image.management.ViewController.pojo.SetViewAttribute;


@Slf4j
public class MainViewApp extends Application {

    public static SetViewAttribute setResizable = new SetViewAttribute();

    @Override
    public void start(Stage stage) {
        // 设置关闭事件
        stage.setOnCloseRequest(event -> {
            SpringBootImageManagementApplication.applicationContext.close();
            log.info("提示: 您已经退出了程序");
            Scene scene = stage.getScene();
            scene.getWindow().hide();
            stage.hide();
            stage.close();
            Platform.exit();

            event.consume();
        });
        stage.setResizable(false);
        setResizable.setPrimaryStage(stage);

        //设置图标
        setResizable.setWindowIcon(IconPath.WindowIcon);

        //获取解码文件 转化为舞台 设置舞台 isEject 弹出显示 isWindowCentered 设置窗口居中
        setResizable.changeView(FxmlPath.Login, true, true);
    }

}
